package cn.wsalix.user.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.MapsId;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import cn.anlaser.entity.BasicEntity;
import cn.wsalix.admin.entity.SysUser;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "USER_CENTER")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Data
@EqualsAndHashCode(callSuper = false)
@ToString(exclude = { "user" })
public class UserCenter extends BasicEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5392803023522006083L;
	@Id
	private Long id;
	@JsonIgnore
	/*
	 * @OneToOne(optional = false, cascade = CascadeType.MERGE)
	 * //@JoinColumn(foreignKey = @ForeignKey(name = "FK_USERCENTER_USER"), name
	 * = "ID", unique = true)
	 * 
	 * @JoinColumn(name = "ID", referencedColumnName = "ID", unique = true)
	 * //@JoinColumn(name = "USER_ID", referencedColumnName = "ID", unique =
	 * true)
	 */
	private Date firstday;// 第一次消费时间
	private Date lastday;// 最后一次消费时间
	private int wastCount;//累计消费
	private int wastNum;//累计次数
	@OneToOne(optional = false, cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
	@MapsId
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_USERCENTER_USER"), name = "ID")
	private SysUser user;// 支付账号
	private Integer loanAmount;// 贷款
	private Integer validAmount;// 可用金额
	private Integer frostAmount;// 冻结金额
	private Integer amount;// 总金额
	private Integer usageAmount;// 消费金额

	private Integer integral;
	private Integer frostIntegral;// 冻结
	private Integer validIntegral;// 消费
}
